package com.stylefeng.guns.modular.flagglory.warpper;

import com.stylefeng.guns.common.persistence.dao.QuestionCategoryMapper;
import com.stylefeng.guns.common.persistence.model.QuestionCategory;
import com.stylefeng.guns.core.base.warpper.BaseControllerWarpper;
import com.stylefeng.guns.core.util.SpringContextHolder;

import java.util.Map;

/**
 * 部门列表的包装
 *
 * @author fengshuonan
 * @date 2017年4月25日 18:10:31
 */
public class QuestionCategoryWarpper extends BaseControllerWarpper {
    private QuestionCategoryMapper questionCategoryMapper = SpringContextHolder.getBean(QuestionCategoryMapper.class);
    public QuestionCategoryWarpper(Object list) {
        super(list);
    }


    @Override
    public void warpTheMap(Map<String, Object> map) {
        Integer pid = (Integer) map.get("pid");
        QuestionCategory pQuestionCategory = questionCategoryMapper.selectById(pid);
        if (null != pQuestionCategory) {
            map.put("pname", pQuestionCategory.getName());
        }else{
            map.put("pname", "顶级");
        }
        Object available = map.get("available");
        if (null != available) {
            if(Boolean.parseBoolean(available.toString())){
                map.put("available", "是");
            }else{
                map.put("available", "否");
            }
        }
    }

}
